<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      
    >
      <el-form-item :label="$t('employing_company')" prop="employerName">
        <el-input v-model="queryParams.employerName" @keyup.enter.native="handleQuery"></el-input>
      </el-form-item>
      <el-form-item
        :label="$t('performance_group')"
        prop="performanceGroupName"
      >
        <el-input v-model="queryParams.performanceGroupName" @keyup.enter.native="handleQuery"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >{{ $t("search") }}</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{
          $t("reset")
        }}</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['performance:performanceStatistics:export']"
          >{{ $t("export") }}</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="attendanceList"
      @selection-change="handleSelectionChange"
      border
      :max-height="tableHeight"
    >
      <el-table-column
        :label="$t('employing_company')"
        align="center"
        prop="employerName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('performance_group')"
        align="center"
        prop="performanceGroupName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('employee_name')"
        align="center"
        prop="employeeName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('performance_appraisal_name')"
        align="center"
        prop="performanceName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('performance_code')"
        align="center"
        prop="performanceCode"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('remarks')"
        align="center"
        prop="remark"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('self_evaluation_score')"
        align="center"
        prop="selfEvaluationScore"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('scoring_average_score')"
        align="center"
        prop="averageScore"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('number_of_questions')"
        align="center"
        prop="questionsQuantity"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('date')"
        align="center"
        prop="giveOutTime"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        :label="$t('reviewed_by')"
        align="center"
        prop="reviewerNickName"
        :show-overflow-tooltip="true"
      />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
      :page-sizes="[10,20,30,50,100, 200]"
    />
  </div>
</template>

<script>
import { getPerformanceStatisticsList } from "@/api/custom/performanceList";

export default {
  name: "Attendance",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 考勤统计表格数据
      attendanceList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        month: null,
        employeeId: null,
        employerName:null,
        performanceGroupName:null,
        employerId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询考勤统计列表 */
    getList() {
      this.loading = true;
      getPerformanceStatisticsList(this.queryParams).then((response) => {
        this.attendanceList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "business/jxPerformanceEmployee/export",
        {
          ...this.queryParams,
        },
        `${this.$t("performance_statistics")}_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
